package ge.gen.eBdgt.graph;

import ge.gen.eBdgt.vo.IcnVO;
import ge.gen.eBdgt.vo.TeamWrkLoadVO;

import java.util.Iterator;
import java.util.List;

import com.gp.api.model.MxStandardChartModel;
import com.gp.api.styles.MxElementStyle;
import com.gp.api.styles.MxMorphStyle;
import com.gp.api.styles.MxStandardConstants;
import com.gp.api.styles.MxElementStyle.Shape;
import com.gp.api.styles.MxStandardConstants.TextOrientation;
import com.gp.api.styles.chart.MxFrameChartStyle;
import com.gp.api.styles.chart.MxFrameStyle;

public class TeamWrkLoadGraph {
	MxFrameChartStyle style = new MxFrameChartStyle();
	MxStandardChartModel model;
	List<TeamWrkLoadVO> teamWrkLoadVOList;

	String imageStream;
	private Shape shape;

	public TeamWrkLoadGraph(List<TeamWrkLoadVO> teamWrkLoadVOList, Shape shape) {
		this.teamWrkLoadVOList = teamWrkLoadVOList;
		this.shape = shape;
	}

	public MxFrameChartStyle getStyle() {
		style.is3D = false;
		style.frame.xDepth = 3;
		style.frame.yDepth = 1;
		style.frame.leftAxisPlacement = MxFrameStyle.AxisPlacement.BACK;
		style.frame.isHStripVisible = true;
		style.frame.background.minColor = new java.awt.Color(253, 254, 246);
		style.xAxis.labelFormat.pattern = "#,##0.###";
		style.xAxis.parseFormat.pattern = "#,##0.###";
		style.legend.decoration.style = MxStandardConstants.Decoration.NONE;
		style.elements.place = MxElementStyle.Place.DEFAULT;
		style.elements.shape = shape;
		style.elements.drawShadow = true;
		style.elements.morph.morph = MxMorphStyle.MorphStyle.GROW;
		style.table.heatmap.isEnabled = false;
		style.table.heatmap.minLevel = "0.0";
		style.table.heatmap.maxLevel = "0.0";
		style.xAxis.labelStyle.orientation = TextOrientation.VERTICAL;
		return style;
	}

	public String getImageStream() {
		return imageStream;
	}

	public void setImageStream(String imageStream) {
		this.imageStream = imageStream;
	}

	public void setStyle(MxFrameChartStyle style) {
		this.style = style;
	}

	public MxStandardChartModel getModel() {
		model = new MxStandardChartModel();
		Iterator<TeamWrkLoadVO> iter = teamWrkLoadVOList.iterator();
		double[] actuals = new double[teamWrkLoadVOList.size()];
		double[] plan = new double[teamWrkLoadVOList.size()];
		int i = 0;
		while (iter.hasNext()) {
			TeamWrkLoadVO vo = iter.next();
			model.insertCol(i+"", null, -1);
//			actuals[i] = vo.get
//			plan[i] = vo.getPlanHrs();
			i++;
		}
		model.insertRow("Actuals", actuals, -1);
		model.insertRow("Plan", plan, -1);
		return model;
	}

	public void setModel(MxStandardChartModel model) {
		this.model = model;
	}

	public MxStandardChartModel setModel() {
		model = new MxStandardChartModel();
		Iterator<TeamWrkLoadVO> iter = teamWrkLoadVOList.iterator();
		double[] actuals = new double[teamWrkLoadVOList.size()];
		double[] plan = new double[teamWrkLoadVOList.size()];
		int num=0;
		while (iter.hasNext()) {
			num++;			
			model.insertCol(num+"", null, -1);
		}
		model.insertRow("Actuals", actuals, -1);
		model.insertRow("Plan", plan, -1);
		return model;
	}

	
	public List<TeamWrkLoadVO> getTeamWrkLoadVOList() {
		return teamWrkLoadVOList;
	}

	public void setTeamWrkLoadVOList(List<TeamWrkLoadVO> teamWrkLoadVOList) {
		this.teamWrkLoadVOList = teamWrkLoadVOList;
	}
}
